#include <db_manager/qls_specification.h>

QLsSpecification::QLsSpecification()
{
}

QString QLsSpecification::isNull(QString key)
{
    return key + " is null";
}

QString QLsSpecification::isNotNull(QString key)
{
    return key + " is not null";
}

QString QLsSpecification::equal(QString key, QString value)
{
    return key + " = " + value;
}

QString QLsSpecification::notEqual(QString key, QString value)
{
    return key + " <> " + value;
}

QString QLsSpecification::like(QString key, QString value)
{
    return key + " like " + value;
}

QString QLsSpecification::Or(QString a, QString b)
{
    return "(" + a + ") or (" + b + ")";
}

QString QLsSpecification::Or(QList<QString> QList)
{
    QString res;

    for (auto it = QList.begin(); it != QList.end(); it++) {
        if (it != QList.begin())
            res += " or ";
        res += "(" + *it + ")";
    }

    return res;
}

QString QLsSpecification::And(QString a, QString b)
{
    return "(" + a + ") and (" + b + ")";
}

QString QLsSpecification::And(QList<QString> QList)
{
    QString res;

    for (auto it = QList.begin(); it != QList.end(); it++) {
        if (it != QList.begin())
            res += " and ";
        res += "(" + *it + ")";
    }

    return res;
}

QString QLsSpecification::tranString(const QString &value)
{
    return "'" + value + "'";
}

QString QLsSpecification::getSqlWhere() const
{
    return sqlWhere;
}

void QLsSpecification::setSqlWhere(const QString &value)
{
    sqlWhere = value;
}
